<template>
  <div class="global">
    <div class="chaxun">
      <el-input
        placeholder="请输入用户名"
        style="width: 160px; margin-right: 10px"
        v-model="name"
      ></el-input>
      <el-button type="primary" @click="chaxun">查询</el-button>
      <el-button @click="chongzhi">重置</el-button>
    </div>
    <el-table :data="tableData">
      <el-table-column label="姓名" prop="name"></el-table-column>
 
      <el-table-column
        label="目前位置"
        prop="currentPosition"
        width="200"
      ></el-table-column>
      <el-table-column label="体温" prop="bodyTemperature"></el-table-column>

      <el-table-column label="健康状况" prop="healthState"></el-table-column>
      <el-table-column label="是否经过高风险地区" prop="isToHighArea"></el-table-column>
      <el-table-column
        label="是否接触过确诊人员"
        prop="isTouch"
      ></el-table-column>
        <el-table-column label="备注" prop="remarks"></el-table-column>
      <el-table-column
        label="打卡时间"
        prop="checkOutDate"
      ></el-table-column>
     
    </el-table>
    <el-pagination
      background
      size-change="handle1"
      current-change="handle"
      style="float: left"
      layout="prev, pager, next"
      :total="total"
    >
    </el-pagination>

    <el-dialog title="病患信息" :visible.sync="dialogVisible1" width="50%">
      <el-descriptions title="用户信息">
        <el-descriptions-item label="姓名">{{
          form.name
        }}</el-descriptions-item>
        <el-descriptions-item label="手机号">{{
          form.phone
        }}</el-descriptions-item>
        <el-descriptions-item label="年龄">{{ form.age }}</el-descriptions-item>
        <el-descriptions-item label="性别">
          {{ form.gender }}
        </el-descriptions-item>
        <el-descriptions-item label="地址">{{
          form.address
        }}</el-descriptions-item>
      </el-descriptions>
    
      <el-descriptions title="治疗信息">
        <el-descriptions-item label="感染源">{{
          form.infectionSource
        }}</el-descriptions-item>
        <el-descriptions-item label="住院时间">{{
          form.onsetDate
        }}</el-descriptions-item>
        <el-descriptions-item label="是否重症">{{
          form.critical
        }}</el-descriptions-item>
        <el-descriptions-item label="发病症状">
          {{ form.symptoms }}
        </el-descriptions-item>
        <el-descriptions-item label="诊治医院">{{
          form.hospital
        }}</el-descriptions-item>
        <el-descriptions-item label="备注">
          {{ form.note }}
        </el-descriptions-item>
      </el-descriptions>
  
      <el-descriptions title="核酸信息"> </el-descriptions>
      <el-table :data="hesuandata">
        <el-table-column label="检测日期" prop="testDate"></el-table-column>
        <el-table-column label="核酸检测" prop="nuTest"></el-table-column>
        <el-table-column label="CT检测" prop="ctTest"></el-table-column>
      </el-table>
    </el-dialog>
    <el-dialog title="转为确诊" :visible.sync="dialogVisibleqz" width="50%">
      <el-form :model="formqz" label-width="130px">
        <el-form-item label="感染源" required>
          <el-input
            placeholder="请输入感染源"
            v-model="formqz.infectionSource"
          ></el-input>
        </el-form-item>
        <el-form-item label="住院时间" required>
          <el-date-picker
            type="date"
            placeholder="请选择时间"
            value-format="yyyy-MM-dd"
            style="width: 100%"
            v-model="formqz.onsetDate"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="症状" required>
          <el-input
            placeholder="请输入症状"
            v-model="formqz.symptoms"
          ></el-input>
        </el-form-item>
        <el-form-item label="诊治医院" required>
          <el-input
            placeholder="请输入医院"
            v-model="formqz.hospital"
          ></el-input>
        </el-form-item>
        <el-form-item label="是否重症" required>
          <el-select
            placeholder="是否重症"
            style="width: 100%"
            v-model="formqz.critical"
          >
            <el-option label="是" value="是"></el-option>
            <el-option label="否" value="否"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="备注" required>
          <el-input
            placeholder="请输入备注"
            type="textarea"
            v-model="formqz.note"
          ></el-input>
        </el-form-item>
        <el-button type="primary" @click="baocunbinghuan()">保存</el-button>
      </el-form>
    </el-dialog>
    <el-dialog title="新增核酸检测" :visible.sync="hsjcdialog" width="50%">
      <el-form :model="ruleForm" label-width="150px">
        <el-form-item label="检测时间" prop="testDate">
          <el-date-picker
            type="date"
            style="width: 100%"
            value-format="yyyy-MM-dd"
            v-model="ruleForm2.testDate"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="CT检测" prop="ctTest">
          <el-select style="width: 100%" v-model="ruleForm2.ctTest">
            <el-option label="病变" value="病变"></el-option>
            <el-option label="正常" value="正常"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="核酸检测" prop="nuTest">
          <el-select style="width: 100%" v-model="ruleForm2.nuTest">
            <el-option label="阴性" value="阴性"></el-option>
            <el-option label="阳性" value="阳性"></el-option>
          </el-select>
        </el-form-item>
        <el-button type="primary" @click="hssubmit()">确定</el-button>
      </el-form>
    </el-dialog>
    <el-dialog title="修改治疗信息" :visible.sync="dialogVisible" width="50%">
      <el-form :model="ruleForm" label-width="150px">
        <el-form-item label="感染源" prop="infectionSource">
          <el-input v-model="ruleForm.infectionSource"></el-input>
        </el-form-item>
        <el-form-item label="住院时间" prop="onsetDate">
          <el-date-picker
            type="date"
            style="width: 100%"
            value-format="yyyy-MM-dd0"
            v-model="ruleForm.onsetDate"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="症状" prop="symptoms">
          <el-input v-model="ruleForm.symptoms"></el-input>
        </el-form-item>
        <el-form-item label="诊治医院" prop="hospital">
          <el-input v-model="ruleForm.hospital"></el-input>
        </el-form-item>
        <el-form-item label="是否重症" prop="critical">
          <el-select v-model="ruleForm.critical" style="width: 100%">
            <el-option label="是" value="是"></el-option>
            <el-option label="否" value="否"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="备注" prop="note">
          <el-input v-model="ruleForm.note"></el-input>
        </el-form-item>
        <el-button type="primary" @click="chongzhi1()">重置</el-button>
        <el-button type="primary" @click="submit()">确定</el-button>
      </el-form>
    </el-dialog>
  </div>
</template>
<script>
import requset from "@/utils/request";
export default {
  data() {
    return {
      ruleForm: {},
      form: {},
      name: "",
      zyform: {},
      hesuandata: [],
      ruleForm2: {},
      swdialog: false,
      formqz: {},
      pageNum: 1,
      hsjcdialog: false,
      zydialog: false,
      swform: {},
      total: 0,
      dialogVisibleqz: false,
      tableData: [],
      dialogVisible: false,
      pageSize: 10,
      dialogVisible1: false,
    };
  },
  mounted() {
    this.getdata();
  },
  methods: {
    qxzsw() {
      this.swform = {};
      this.swdialog = false;
    },
    zwsw(row){
      this.swform = {};
      this.swdialog = true;

      this.swform.baseId = row.baseId;
   
    },
    zwzy(row) {
      this.zyform = {};
      this.zydialog = true;

      this.zyform.baseId = row.baseId;
    },
    qxzzy() {
      this.zyform = {};
      this.zydialog = false;
    },
    async baocunzy() {
      const res = await requset.post("/base/savezy", this.zyform);
      if (res.data.code == 200) {
        this.zydialog = false;
        this.getdata();
      }
    },
    async baocunsw() {
      const res = await requset.post("/base/savesw", this.swform);
      if (res.data.code == 200) {
        this.swdialog = false;
        this.getdata();
      }
    },
    async hssubmit() {
      const res = await requset.post("/base/savehs", {
        baseId: this.form.baseId,
        testDate: this.ruleForm2.testDate,
        ctTest: this.ruleForm2.ctTest,
        nuTest: this.ruleForm2.nuTest,
      });
      if (res.data.code == 200) {
        this.hsjcdialog = false;
        this.gethesuan();
      }
    },
    tjhsxx() {
      this.hsjcdialog = true;
    },
    async baocunbinghuan() {
      const res = await requset.post("/patient/add", this.formqz);
      const res1 = await requset.post("/base/glwc", {
        baseId: this.formqz.baseId,
      });
      console.log(res);
      if (res.data.code == 200) {
        this.$message.success("新增成功");
        this.dialogVisibleqz = false;
        this.getdata();
      }
    },
    zwqz(row) {
      console.log(row);
      this.formqz = {};
      this.formqz.baseId = row.baseId;
      this.dialogVisibleqz = true;
    },
    xgzlxx() {
      this.dialogVisible = true;
      this.ruleForm = this.form;
    },
    detail(row) {
      console.log(row);
      this.form = row;
      this.dialogVisible1 = true;
      this.gethesuan();
    },
    async gethesuan() {
      const res = await requset.get(`/base/cxhsxx?baseId=${this.form.baseId}`);
      console.log(res);
      this.hesuandata = res.data.data;
    },

    glwc(row) {
      this.$confirm("是否确认隔离完成?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(async () => {
          const res = await requset.post("/base/glwc", { baseId: row.id });
          if (res.data.code == 200) {
            this.$message({
              type: "success",
              message: "修改成功!",
            });
            this.getdata();
          }
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },
    chongzhi1() {
      this.ruleForm = {};
    },
    async submit() {
      console.log(this.ruleForm.note);

      const res = await requset.post("/base/xgzlxx", {
        baseId: this.ruleForm.baseId,
        infectionSource: this.ruleForm.infectionSource,
        symptoms: this.ruleForm.symptoms,
        onsetDate: this.ruleForm.onsetDate,
        critical: this.ruleForm.critical,
        hospital: this.ruleForm.hospital,
        note: this.ruleForm.note,
      });

      console.log(res);

      if (res.data.code == 200) {
        this.$message.success("修改成功");
        this.dialogVisible = false;
        this.getdata();
      }
    },
    xinzeng() {
      this.dialogVisible = true;
      this.ruleForm = {};
    },
    chongzhi() {
      this.name = "";
      this.pageNum = 1;
      this.pageSize = 10;
      this.getdata();
    },
    chaxun() {
      this.pageNum = 1;
      this.pageSize = 10;
      this.getdata();
    },
    handle(e) {
      this.pageNum = e;
      this.getdata();
    },
    handle1(e) {
      this.pageSize = e;
      this.getdata();
    },
    async getdata() {
      const res = await requset.get(
        `/rydk/index?pageNum=${this.pageNum}&&pageSize=${this.pageSize}&&name=${this.name}`
      );
      console.log(res);
      this.tableData = res.data.data;
      this.total = res.data.total;
    },
  },
};
</script>
<style scoped>
.chaxun {
  display: flex;
  justify-content: start;
}
.global {
  width: 100%;
  height: 100%;
  background: #fff;
  padding: 15px;
  box-sizing: border-box;
}
</style>